package com.example.exampleproject.base;

import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.disposables.Disposable;

public abstract class BasePresenter<V extends IView> implements IPresenter<V>{

    private CompositeDisposable disposables = new CompositeDisposable();

    private V mView;

    @Override
    public void attachView(V view) {
        mView = view;
    }

    @Override
    public void detachView() {
        mView = null;
        if (disposables != null) {
            disposables.clear();
        }
    }

    protected void addSubscription(Disposable disposable) {
        if (disposable != null) {
            disposables.add(disposable);
        }
    }

    public V getView() {
        return mView;
    }
}
